package main

import (
	"fmt"
	"time"
)

func isAnagram(s string, t string) bool {

	m := len(s)
	n := len(t)

	if m != n {
		return false
	}

	// 把ransoNOte,magazine转换为字典

	count := make(map[byte]int)
	for i := 0; i < m; i++ {
		count[s[i]]++
		count[t[i]]--
	}

	for _, vaule := range count {
		if vaule != 0 {
			return false
		}
	}
	return true

}

func main() {
	start := time.Now()
	s, t := "rat", "car"
	dec := isAnagram(s, t)
	cost := time.Since(start)
	fmt.Println(dec)
	fmt.Println(cost)

}
